function deepCopy(target){ 
  let copyed_objs = [];//此数组解决了循环引用和相同引用的问题，它存放已经递归到的目标对象 
  function _deepCopy(target){ 
      if((typeof target !== 'object')||!target){return target;}
      for(let i= 0 ;i<copyed_objs.length;i++){
          if(copyed_objs[i].target === target){
              return copyed_objs[i].copyTarget;
          }
      }
      let obj = {};
      if(Array.isArray(target)){
          obj = [];//处理target是数组的情况 
      }
      copyed_objs.push({target:target,copyTarget:obj}) 
      Object.keys(target).forEach(key=>{ 
          if(obj[key]){ return;} 
          obj[key] = _deepCopy(target[key]);
      }); 
      return obj;
  } 
  return _deepCopy(target);
}
  
var a = {
  arr:[1,2,3,{key:'123'}],//数组测试
};
a.self = a;//循环引用测试
a.common1 = {name:'ccc'};
a.common2 = a.common1;//相同引用测试
var c = deepCopy(a);
c.common1.name = 'changed';
console.log(c);